﻿package com.tudou.home.newskin.buttons
{
    import com.tudou.consts.*;
    import com.tudou.home.common.button.*;
    import com.tudou.home.newskin.consts.*;
    import com.tudou.home.newskin.events.*;
    import com.tudou.home.newskin.model.*;
    import com.tudou.home.utils.*;
    import com.tudou.skin.*;
    import com.tudou.utils.*;
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;

    public class RelativeVideo extends Sprite
    {
        private var durationText:TextField;
        private var playCount:IconText;
        private var durationBlack:DisplayObject;
        private var thisIndex:int;
        private var commentCount:IconText;
        private var title:IconText;
        private var photoFrame:PhotoFrame;

        public function RelativeVideo(param1:IBaseVideoInfo, param2:int, param3:Boolean = false)
        {
            var icon:DisplayObject;
            var openType:String;
            var clickHlr:Function;
            var iBaseVideoInfo:* = param1;
            var index:* = param2;
            var showTransFinished:* = param3;
            clickHlr = function (event:MouseEvent) : void
            {
                FullScreen.getInst().exitFullScreen();
                SingleItemOpenUrl.openType = openType;
                dispatchEvent(new SkinEvent(SkinEvent.SINGLE_THIS_INDEX, thisIndex));
                return;
            }// end function
            ;
            var totalWidth:* = NewSkinConsts.RELATIVE_ITEM_WIDTH;
            var totalHeight:* = NewSkinConsts.RELATIVE_ITEM_HEIGTH;
            var frame1Width:* = NewSkinConsts.RELATIVE_FRAME1_WIDTH;
            var frame1Height:* = NewSkinConsts.RELATIVE_FRAME1_HEIGTH;
            var HdWidth:* = NewSkinConsts.HD_ICON_WIDTH;
            var HdHeight:* = NewSkinConsts.HD_ICON_HEIGHT;
            RectDisplayUtil.drawRect(graphics, totalWidth, totalHeight, 0, 0);
            photoFrame = new PhotoFrame();
            photoFrame.load(iBaseVideoInfo.frame1URL);
            photoFrame.setFrameColorAlpha(NewSkinConsts.FRAME1_FRAMELINE_COLOR, 1);
            photoFrame.setWidthHeight(frame1Width, frame1Height);
            addChild(photoFrame);
            thisIndex = index;
            durationBlack = RectDisplayUtil.getShape(frame1Width, 20, 0, 0.5);
            durationBlack.y = photoFrame.height - durationBlack.height;
            addChild(durationBlack);
            durationText = TextFieldUtil.getTextField();
            durationText.text = iBaseVideoInfo.duration;
            durationText.textColor = 16777215;
            durationText.y = durationBlack.y;
            addChild(durationText);
            title = new HrefIconText(frame1Width);
            var maxRateType:* = iBaseVideoInfo.maxRateType;
            switch(maxRateType)
            {
                case RateType.P360:
                {
                    icon = new P360IconMC();
                    break;
                }
                case RateType.P480:
                {
                    icon = new P480IconMC();
                    break;
                }
                case RateType.P720:
                {
                    icon = new P720IconMC();
                    break;
                }
                default:
                {
                    break;
                    break;
                }
            }
            if (icon)
            {
                title.icon = icon;
            }
            title.title = iBaseVideoInfo.title;
            title.textFormat = new TextFormat("宋体", 12, 10066329);
            title.refresh();
            title.y = photoFrame.y + frame1Height + 8;
            addChild(title);
            var _loc_5:Boolean = true;
            this.buttonMode = true;
            this.useHandCursor = _loc_5;
            this.addEventListener(MouseEvent.CLICK, clickHlr);
            openType = showTransFinished ? (SingleItemOpenUrl.TRANS_FINISH_CLICK) : (SingleItemOpenUrl.FINISH_CLICK);
            return;
        }// end function

    }
}
